#pragma once

#include <string>
#include <set>
#include <functional>
#include "Singleton.h"
#include "MsgRouter.h"
#include "agencyevent.h"

class AgencyEventService
{
public:
    bool Init();

public:
    AgencyEventService() = default;
    virtual ~AgencyEventService() = default;

public:
    static AgencyEventService* Instance()
	{
		return CSingleton<AgencyEventService>::Instance();
	}

public:
    enum Sence
    {
        SHARE_POSTER = 100,
        NOTIFY = 101,
        MAIL = 102,
        MATCHREG = 109,                 // 赛事报名
        MATCHUNREG = 110,               // 取消赛事报名
        MATCHSETTLEMENT = 111,          // 赛事结算
        USERINFO = 112,          // 获取玩家信息
		MATCHREWARD = 113,              // 赛事任务派奖
        REPORTTICKET = 114,             // 上报门票信息
        PURCHASE = 115,                 // 0元购 购买
        CANCELPURCHASE = 116,           // 0元购 撤单
    };
public:
    bool HandleGetAgencyEvent(const std::uint32_t& agencyid, std::string&& trans, Sence sence);
    void OnAgencyEventGet(MsgData&& data);
    void OnSenceAgencyEventGet(Sence sence, std::string&& trans, std::int32_t err_code, stAgencyEvent* agency);
    inline void ListenOnAgencyEventGet(Sence sence, std::function<void(std::int32_t err_code, stAgencyEvent*  agency, std::string&& trans)> listen)
    {
        m_agencyevent_get_listen[sence] = listen;
    }
private:
    std::map<Sence, std::function<void(std::int32_t err_code, stAgencyEvent* agencyevent, std::string&& trans)>> m_agencyevent_get_listen;

};










